;; --enable-threads
(module
  ;; (import "env" "m0" (memory $m0 1 8 shared))
  (memory $m1 1 8 shared)
  (func $LS (param $addr i32)
    (i32.atomic.store offset=0 (local.get $addr)
      (i32.atomic.load offset=0 (local.get $addr))
    )
    (i64.atomic.store16 offset=0 (local.get $addr)
      (i64.atomic.load16_u offset=0 (local.get $addr))
    )
  )
  (func $RMW (param $addr i32) (param $val i32)
    (i32.atomic.rmw.add  offset=0 (local.get $addr) (local.get $val)) (drop)
    (i32.atomic.rmw.sub  offset=0 (local.get $addr) (local.get $val)) (drop)
    (i32.atomic.rmw.and  offset=0 (local.get $addr) (local.get $val)) (drop)
    (i32.atomic.rmw.or   offset=0 (local.get $addr) (local.get $val)) (drop)
    (i32.atomic.rmw.xor  offset=0 (local.get $addr) (local.get $val)) (drop)
    (i32.atomic.rmw.xchg offset=0 (local.get $addr) (local.get $val)) (drop)
  )
  (func $CAX (param $addr i32) (param $expected i32) (param $replacement i32)
    (local $loaded i32)
    (i32.atomic.rmw.cmpxchg offset=0
      (local.get $addr) (local.get $expected) (local.get $replacement)
    )
    (local.set $loaded)
  )
  (func $wait (param $addr i32) (param $expected i32) (param $timeout i64)
    (local $wait_ret i32)
    (i32.atomic.wait
      (local.get $addr) (local.get $expected) (local.get $timeout) 
    )
    (local.set $wait_ret)
  )
  (func $notify (param $addr i32) (param $count i32)
    (local $woken_waiters i32)
    (atomic.notify (local.get $addr) (local.get $count))
    (local.set $woken_waiters)
  )
  ;; (func $fence atomic.fence)
)